package com.ce.common.db.dump;

import static org.junit.Assert.assertEquals;

import java.util.ArrayList;
import java.util.List;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.ce.common.db.base.DataObject;
import com.ce.common.db.base.Database;
import com.ce.common.db.base.PropertiesUtil;
import com.ce.common.db.dump.DumpCommand;
import com.ce.common.db.dump.DumpContext;
import com.ce.common.db.dump.mysql.MySQLDumpCommand;

/**
 * 导出的测试类
 * @author yangenxiong
 *
 */
public class DumpContextT {

	Database db;
	
	DumpCommand dump;
	
	@Before
	public void setUp() {
		db = new Database(PropertiesUtil.JDBC_USERNAME, PropertiesUtil.JDBC_PASSWD, 
				PropertiesUtil.JDBC_DATABASE, PropertiesUtil.JDBC_HOST, "UTF8");
		dump = new MySQLDumpCommand(db);
	}
	
	@After
	public void tearDown() {
		db = null;
		dump = null;
	}
	
	@Test
	public void testExecuteCommand() throws Exception {
		DumpContext ctx = new DumpContext();
		ctx.setDumpCommand(dump);
		//将整个库导出
		boolean result = ctx.executeCommand(null, "src/test/resources/test_all.sql");
		assertEquals(result, true);//执行成功
	}
}
